package com.mt.demo.service.impl;

import com.mt.demo.util.DateUtils;
import com.mt.demo.domain.MtMember;
import com.mt.demo.mapper.MtMemberMapper;
import com.mt.demo.service.IMtMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 参会成员Service业务层处理
 * 
 * @author gary
 * @date 2025-08-11
 */
@Service
public class MtMemberServiceImpl implements IMtMemberService 
{
    @Autowired
    private MtMemberMapper mtMemberMapper;

    /**
     * 查询参会成员
     * 
     * @param memberId 参会成员主键
     * @return 参会成员
     */
    @Override
    public MtMember selectMtMemberByMemberId(Long memberId)
    {
        return mtMemberMapper.selectMtMemberByMemberId(memberId);
    }

    /**
     * 根据用户ID查询参会成员
     * 
     * @param userId 用户ID
     * @return 参会成员
     */
    @Override
    public MtMember selectMtMemberByUserId(Long userId)
    {
        MtMember member = new MtMember();
        member.setUserId(userId);
        List<MtMember> members = mtMemberMapper.selectMtMemberList(member);
        return members.isEmpty() ? null : members.get(0);
    }

    /**
     * 查询参会成员列表
     * 
     * @param mtMember 参会成员
     * @return 参会成员
     */
    @Override
    public List<MtMember> selectMtMemberList(MtMember mtMember)
    {
        return mtMemberMapper.selectMtMemberList(mtMember);
    }

    /**
     * 新增参会成员
     * 
     * @param mtMember 参会成员
     * @return 结果
     */
    @Override
    public int insertMtMember(MtMember mtMember)
    {
        mtMember.setCreateTime(DateUtils.getNowDate());
        return mtMemberMapper.insertMtMember(mtMember);
    }

    /**
     * 修改参会成员
     * 
     * @param mtMember 参会成员
     * @return 结果
     */
    @Override
    public int updateMtMember(MtMember mtMember)
    {
        mtMember.setUpdateTime(DateUtils.getNowDate());
        return mtMemberMapper.updateMtMember(mtMember);
    }

    /**
     * 批量删除参会成员
     * 
     * @param memberIds 需要删除的参会成员主键
     * @return 结果
     */
    @Override
    public int deleteMtMemberByMemberIds(Long[] memberIds)
    {
        return mtMemberMapper.deleteMtMemberByMemberIds(memberIds);
    }

    /**
     * 删除参会成员信息
     * 
     * @param memberId 参会成员主键
     * @return 结果
     */
    @Override
    public int deleteMtMemberByMemberId(Long memberId)
    {
        return mtMemberMapper.deleteMtMemberByMemberId(memberId);
    }
}
